# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models


class user(models.Model):
    # 用户id 主键
    user_id = models.AutoField(primary_key=True),
    # 用户名
    username = models.CharField(max_length=20, null=False, unique=True)
    # 用户密码
    password = models.CharField(max_length=50, null=False)
    # 身份，身份对应用户权限
    identity = models.IntegerField()
    # 邮箱
    email = models.EmailField(max_length=50, null=True)
    # 电话
    tel = models.CharField(max_length=50, null=True)


class event(models.Model):
    # 底事件ID 主键
    id = models.AutoField(primary_key=True)
    # 事件
    events = models.CharField(max_length=50, null=True,unique=True)
    # 事件类型
    type = models.CharField(max_length=50, null=True)
    # pid
    pid = models.IntegerField(null=False)
    # path
    path = models.CharField(max_length=200, null=True, unique=True)
    # 描述
    describe = models.CharField(max_length=50, null=True)
    # 特征码
    signature = models.CharField(max_length=50, null=False, unique=True)


'''
故障日志
'''


class info(models.Model):
    # 主键
    fault_id = models.AutoField(primary_key=True)
    # 故障事件
    fault_events = models.CharField(max_length=2000)
    # 最后发生时间
    fault_time = models.DateTimeField(auto_now=True)
    # # 发生次数
    # fault_num = models.IntegerField(default=1)


class log(models.Model):
    # 主键
    id = models.AutoField(primary_key=True)
    # 日志
    log = models.CharField(max_length=2000)
    # 最后发生时间
    fault_time = models.DateTimeField(auto_now=True)
